<template>
  <div class="error-404">
    <div class="error-container">
      <div class="error-content">
        <!-- 404 图标 -->
        <div class="error-icon">
          <div class="number-404">
            <span class="four">4</span>
            <span class="zero">0</span>
            <span class="four">4</span>
          </div>
        </div>
        
        <!-- 错误信息 -->
        <div class="error-info">
          <h1 class="error-title">页面未找到</h1>
          <p class="error-description">
            抱歉，您访问的页面不存在或已被移除。
          </p>
          <p class="error-suggestion">
            请检查网址是否正确，或者返回首页继续浏览。
          </p>
        </div>
        
        <!-- 操作按钮 -->
        <div class="error-actions">
          <el-button type="primary" size="large" @click="goHome">
            <el-icon><House /></el-icon>
            返回首页
          </el-button>
          <el-button size="large" @click="goBack">
            <el-icon><ArrowLeft /></el-icon>
            返回上页
          </el-button>
          <el-button size="large" @click="refresh">
            <el-icon><Refresh /></el-icon>
            刷新页面
          </el-button>
        </div>
        
        <!-- 快速导航 -->
        <div class="quick-nav">
          <h3>您可能想要访问：</h3>
          <div class="nav-links">
            <router-link to="/classroom" class="nav-link">
              <div class="link-icon">
                <el-icon><VideoPlay /></el-icon>
              </div>
              <div class="link-content">
                <div class="link-title">智慧课堂</div>
                <div class="link-desc">在线学习课程</div>
              </div>
            </router-link>
            
            <router-link to="/coding" class="nav-link">
              <div class="link-icon">
                <el-icon><Code /></el-icon>
              </div>
              <div class="link-content">
                <div class="link-title">编程练习</div>
                <div class="link-desc">算法题目练习</div>
              </div>
            </router-link>
            
            <router-link to="/task" class="nav-link">
              <div class="link-icon">
                <el-icon><Document /></el-icon>
              </div>
              <div class="link-content">
                <div class="link-title">学习任务</div>
                <div class="link-desc">个性化学习计划</div>
              </div>
            </router-link>
            
            <router-link to="/news" class="nav-link">
              <div class="link-icon">
                <el-icon><Notification /></el-icon>
              </div>
              <div class="link-content">
                <div class="link-title">资讯中心</div>
                <div class="link-desc">最新技术资讯</div>
              </div>
            </router-link>
          </div>
        </div>
      </div>
      
      <!-- 装饰元素 -->
      <div class="decoration">
        <div class="floating-shapes">
          <div class="shape shape-1"></div>
          <div class="shape shape-2"></div>
          <div class="shape shape-3"></div>
          <div class="shape shape-4"></div>
          <div class="shape shape-5"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { 
  House, ArrowLeft, Refresh, VideoPlay, Code, 
  Document, Notification
} from '@element-plus/icons-vue'

const router = useRouter()

// 方法
const goHome = () => {
  router.push('/')
}

const goBack = () => {
  if (window.history.length > 1) {
    router.go(-1)
  } else {
    router.push('/')
  }
}

const refresh = () => {
  window.location.reload()
}
</script>

<style lang="scss" scoped>
.error-404 {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.error-container {
  max-width: 800px;
  width: 100%;
  text-align: center;
  position: relative;
  z-index: 2;
}

.error-content {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 60px 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  
  @media (max-width: 768px) {
    padding: 40px 20px;
  }
}

.error-icon {
  margin-bottom: 40px;
}

.number-404 {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  
  span {
    font-size: 120px;
    font-weight: 900;
    line-height: 1;
    
    @media (max-width: 768px) {
      font-size: 80px;
    }
    
    &.four {
      color: var(--el-color-primary);
      animation: bounce 2s infinite;
    }
    
    &.zero {
      color: var(--el-color-danger);
      animation: bounce 2s infinite 0.2s;
    }
  }
}

.error-info {
  margin-bottom: 40px;
  
  .error-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--el-text-color-primary);
    margin-bottom: 16px;
    
    @media (max-width: 768px) {
      font-size: 24px;
    }
  }
  
  .error-description {
    font-size: 18px;
    color: var(--el-text-color-regular);
    margin-bottom: 12px;
    
    @media (max-width: 768px) {
      font-size: 16px;
    }
  }
  
  .error-suggestion {
    font-size: 16px;
    color: var(--el-text-color-secondary);
    
    @media (max-width: 768px) {
      font-size: 14px;
    }
  }
}

.error-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 50px;
  
  @media (max-width: 768px) {
    flex-direction: column;
    align-items: center;
    
    .el-button {
      width: 200px;
    }
  }
}

.quick-nav {
  h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--el-text-color-primary);
    margin-bottom: 24px;
  }
}

.nav-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  
  @media (max-width: 768px) {
    grid-template-columns: 1fr;
  }
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--el-fill-color-extra-light);
  border-radius: 12px;
  text-decoration: none;
  transition: all 0.3s ease;
  
  &:hover {
    background: var(--el-color-primary-light-9);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  }
  
  .link-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--el-color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
  }
  
  .link-content {
    text-align: left;
    
    .link-title {
      font-size: 16px;
      font-weight: 600;
      color: var(--el-text-color-primary);
      margin-bottom: 2px;
    }
    
    .link-desc {
      font-size: 12px;
      color: var(--el-text-color-secondary);
    }
  }
}

.decoration {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 1;
}

.floating-shapes {
  position: relative;
  width: 100%;
  height: 100%;
}

.shape {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  animation: float 6s ease-in-out infinite;
  
  &.shape-1 {
    width: 80px;
    height: 80px;
    top: 10%;
    left: 10%;
    animation-delay: 0s;
  }
  
  &.shape-2 {
    width: 60px;
    height: 60px;
    top: 20%;
    right: 15%;
    animation-delay: 1s;
  }
  
  &.shape-3 {
    width: 100px;
    height: 100px;
    bottom: 20%;
    left: 15%;
    animation-delay: 2s;
  }
  
  &.shape-4 {
    width: 40px;
    height: 40px;
    bottom: 30%;
    right: 20%;
    animation-delay: 3s;
  }
  
  &.shape-5 {
    width: 70px;
    height: 70px;
    top: 50%;
    left: 5%;
    animation-delay: 4s;
  }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  33% {
    transform: translateY(-20px) rotate(120deg);
  }
  66% {
    transform: translateY(10px) rotate(240deg);
  }
}

// 响应式设计
@media (max-width: 480px) {
  .error-content {
    padding: 30px 15px;
  }
  
  .number-404 {
    span {
      font-size: 60px;
    }
  }
  
  .error-title {
    font-size: 20px !important;
  }
  
  .error-description {
    font-size: 14px !important;
  }
  
  .error-suggestion {
    font-size: 12px !important;
  }
  
  .nav-links {
    gap: 12px;
  }
  
  .nav-link {
    padding: 12px;
    
    .link-icon {
      width: 32px;
      height: 32px;
      font-size: 16px;
    }
    
    .link-title {
      font-size: 14px;
    }
    
    .link-desc {
      font-size: 11px;
    }
  }
}
</style>
